using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;

namespace AvalonAdmin.Converters
{
    /// <summary>
    /// 布尔值到颜色转换器
    /// true -> 绿色 (启用/激活状态)
    /// false -> 红色 (禁用/非激活状态)
    /// </summary>
    public class BooleanToColorConverter : IValueConverter
    {
        public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is bool boolValue)
            {
                // true 返回绿色，false 返回红色
                return boolValue ? Brushes.Green : Brushes.Red;
            }
            
            // 默认返回灰色
            return Brushes.Gray;
        }

        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            // 不支持反向转换
            throw new NotImplementedException();
        }
    }
}